package com.mars.demo.service;

import com.mars.demo.model.User;
import com.mars.demo.service.impl.UserFeignClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

// value 指定需要调用的 provider 在注册中心里的名字
// fallback 指定容错处理类
@FeignClient(value = "dm-cloud-user-provider", fallback = UserFeignClientFallback.class)
public interface UserFeignClient {

    // 返回值、参数、方法名、访问方式都要和 provider 保持一致
    // Feign 组件才能正确的访问对应的方法
    @RequestMapping(value = "/user/login", method = RequestMethod.POST)
    public String login(@RequestBody User user);

    @RequestMapping(value = "/test/ribbon", method = RequestMethod.GET)
    public String testRibbon(@RequestParam("count") int count);

}
